<?php 

namespace pmvc\mvc\security;

class MD5PasswordEncoder
	implements PasswordEncoder {

	private $salt			= null;
	private $saltPrefix		= null;
	private $saltPostfix	= null;

	function encode($password) {
		$password = ($this->salt!=null) 		? $this->salt.$password 		: $password;
		$password = ($this->saltPrefix!=null) 	? $this->saltPrefix.$password 	: $password;
		$password = ($this->saltPostfix!=null) 	? $password.$this->saltPostfix 	: $password;
		return md5($password);
	}

	public function setSalt($salt) {
		$this->salt = $salt;
	}

	public function setSaltPrefix($saltPrefix) {
		$this->saltPrefix = $saltPrefix;
	}

	public function setSaltPostfix($saltPostfix) {
		$this->saltPostfix = $saltPostfix;
	}

}

?>